home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu181.dms / pu181.adf / Render.doc < prev    next >
Text File  |  1992-03-22  |  10KB  |  249 lines

  1.  
  2.                             \\\\\\\\|////////
  3.  
  4.                                Render V1.0
  5.  
  6.                             ////////|\\\\\\\\
  7.  
  8. James Shaw April 1992
  9.  
  10. Distribution
  11. ~~~~~~~~~~~~
  12. This program may be freely distributed.  No charge whatsoever may be made
  13. for this distribution other than a reasonable cost for its duplication.  I
  14. consider this to be less than £3.  I have placed it in the Public Domain
  15. because I am not allowed to make any profit from it as the original
  16. program came directly from a book.  If you feel you must make some donation
  17. for its use, buy the book, or send something to charity.
  18.  
  19. Disclaimer
  20. ~~~~~~~~~~
  21. This program is provided as is, and no responsibility for its suitability
  22. for any task is taken by the programmer or the distributer of this software.
  23.  
  24. Introduction
  25. ~~~~~~~~~~~~
  26. This program is a 3D graphics shading program.  It implements two different
  27. methods of getting a realistic 3D look mapped onto a surface constructed of
  28. a set of polygons.  It is not a ray-trace program (ie. there are no shadows
  29. or reflections and the like), but some very impressive pictures can be
  30. produced very simply.
  31.  
  32. History
  33. ~~~~~~~
  34. This program was converted from a project set to 3rd Year Software
  35. Engineering Graphics students at Sheffield University term 1 1992.
  36. The original Stonybrook Modula2 source code was taken from 5Mb Viglen 386sx
  37. PC AT's with 256 colour Super VGA graphics cards.
  38. The original pseudo-code was taken from the book Fundamentals of Three-
  39. Dimensional Computer Graphics by Alan H. Watt from Sheffield University,
  40. published in 1989 by Addison-Wesley ISBN 0201154420.
  41. Matthew Barker converted the raw source to work with Benchmark Modula2 and
  42. since then I have converted the graphics and input/output to work with the
  43. Amiga's Intuition library, and added the dithering routine.
  44.  
  45. Instructions
  46. ~~~~~~~~~~~~
  47. From Workbench:
  48.   Double Click on the Render icon to run the program.
  49. From CLI:
  50.   Set the stack size to somewhere around 100K by typing -
  51.    Stack 100000
  52.   then run the program in the normal way
  53.   ie. Render   or  Run Render
  54.  
  55. It is important to set the stack size to something quite large because
  56. Benchmark code uses the CLI/Workbench stack to store the data for objects.
  57. The stack size is automatically set when run from workbench.
  58. To change the stacksize from workbench you must change the value in the
  59. stacksize gadget in the Render.info icon's info screen.
  60.  
  61. When the program loads a window will open on the workbench screen.
  62. A number of options are available.
  63.  
  64.  O - Load Object
  65.  ~~~~~~~~~~~~~~~
  66.      Type the name of the object to be loaded.  If the object exists
  67.      in the :Render/Objects drawer then it will be loaded.
  68.      Objects can ONLY be loaded from this drawer.
  69.      When objects are loaded the currently loaded objects remain in the
  70.      memory. ie. To remove objects from the scene you will need to quit and
  71.      restart the program, though you could conceivably scale the current
  72.      objects to 0 x 0 x 0 in size!  Once loaded the program will ask you if
  73.      you want to transform the object in any way.  See next section for
  74.      details.
  75.      There are currently ten objects on this disk :-
  76.        Cube - A cube(!),  Cyl - A cylinder.  Sphere - A sphere(!),
  77.        Teapot - A teapot(!),  Torus - A torus(!),
  78.        TBase, TBody, THandle, TLid, TSpout - The elements that are combined
  79.                                              to make the Teapot object.
  80.      Some objects will need to be scaled before they can be viewed, ie.
  81.      the teapot should be scaled by 0.5 on all axes before going, or else
  82.      the computer may guru!  (Have you ever tried blitting a line directly
  83.      through a program and then asking it to run?! - Come on Commodore,
  84.      let's have an MMU next time round!)
  85.  
  86.  T - Transform
  87.  ~~~~~~~~~~~~~
  88.      Select the number of the object to be transformed. You will then be 
  89.      asked to select whether you want to perform a displacement, rotation,
  90.      scaling or no translation to the selected object.
  91.  
  92.      i)   Displacement
  93.           ~~~~~~~~~~~~
  94.           You will be asked to provide x, y & z displacements for the
  95.           object.  These displacements are screen co-ordinate values.
  96.  
  97.      ii)  Rotation
  98.           ~~~~~~~~
  99.           You will be asked to provide x, y & z rotations for the
  100.           object.  These rotations are in degrees.
  101.  
  102.      iii) Scaling
  103.           ~~~~~~~
  104.           You will be asked to provide x, y & z scale factors for the
  105.           object.  These scalings are relative to the current size of
  106.           the object.
  107.  
  108.  W - Wireframe
  109.  ~~~~~~~~~~~~~
  110.      This gives a wireframe representation of the scene which is to be
  111.      rendered.  You will be asked if you would like to view the vertex
  112.      normals.  If you select 'y' then small red lines will be drawn on
  113.      the wireframe indicating the direction of the normal to the polygon.
  114.  
  115.  G - Gouraud
  116.  ~~~~~~~~~~~
  117.      Displays the image shaded using the Gouraud shading algorithm.
  118.  
  119.  P - Phong
  120.  ~~~~~~~~~
  121.      Displays the image shaded using the Phong shading algorithm.
  122.      NB. There is a bug in this algorithm which does not take into
  123.          account the direction of the light source.
  124.  
  125.  B - Both
  126.  ~~~~~~~~
  127.      Displays both shading methods on screen at the same time.
  128.      You must first scale all objects so that they will still fit on
  129.      the screen.
  130.  
  131.  M - Move Viewpoint
  132.  ~~~~~~~~~~~~~~~~~~
  133.      Changes the direction that the object is looked at from.
  134.      You will be asked to enter values for Rho, Theta & Phi and Distance.
  135.      The former three values are the viewing angle and the latter is how
  136.      far away the object is to be viewed from.
  137.  
  138.  L - Move Lightsource
  139.  ~~~~~~~~~~~~~~~~~~~~
  140.      Changes the position of the lightsource.
  141.      You will be asked to enter values for x, y & z.  These are the global
  142.      coordinates of the lightsources new position.
  143.  
  144.  E - Exit
  145.  ~~~~~~~~
  146.      Frees up system memory and quits the program.
  147.  
  148. Implementation
  149. ~~~~~~~~~~~~~~
  150. Currently the program renders into a Low-Res 640 x 512  32 colour screen.
  151. The reason for this is because the image is rendered in the left (visible)
  152. half of the screen, and the right (hidden) half contains the z-buffer for
  153. the image.  This z-buffer is a graphical representation of how far away
  154. specific polygons are in the image at the current time.  For any polygon to
  155. be rendered it must be in front of any which have already been drawn.  On
  156. the PC version the z-buffer is visible, but due to the fact the Amiga can 
  157. only handle 32 colours on a low-res screen and that the images were very
  158. poor when they contained only 16 colours it seemed like this was the best
  159. compromise for the screen resolution.  It does mean, though, that all
  160. objects must be scaled to suit the screen aspect and that when objects are
  161. rotated they will look a bit odd.
  162. The images are currently rendered using 64 colours, and then this value is
  163. converted into a dithering of 32 colours for the actual image.  This gives
  164. lovely results!
  165. There is a problem with the program in that it does not appear to free up
  166. all the memory it has used once it has been exited.  I will try to fix it
  167. for the next release.
  168. When the image is rendering, avoid clicking on the image screen, as this
  169. will deselect the workbench Render window.  This window needs to remain
  170. selected while the image is rendering because only a keypress directed into
  171. this window will get back to the menu and clear the image screen.
  172. I very much doubt if this program will run with less than 1Mb of memory.
  173. There is currently no save screen option in this program.  As a stop gap I
  174. have included a shareware program called ClipIt! by Mike Scalora.  Read the
  175. instructions included in the ClipIt directory on how to operate this program.
  176. If you use it please send Mike his shareware contribution.
  177.  
  178. If you want to know the method of operation of any of the algorithms in this
  179. program, I suggest you get a hold of Alan Watt's book mentioned in the
  180. introduction.
  181.  
  182. Objects
  183. ~~~~~~~
  184. There are a number of objects already stored on the disk.  As there is no
  185. object creator, here is the file structure of the objects so you can create
  186. your own.
  187.  
  188.   No. of vertices in object (N)
  189.   1 x1 y1 z1                                      { All values
  190.   2 x2 y2 z2                                      xn yn zn are reals }
  191.   3 x3 y3 z3                                      
  192.   ...
  193.   N xN yN zN
  194.   No. of sub-objects in main object (M)           { All values
  195.   No. of polygons in object 1 (P)                   vn are integers }
  196.   No. of vertices in polygon 1 (Q)  v1 v2 v3 ... vQ    
  197.   No. of vertices in polygon 2 (Q)  v1 v2 v3 ... vQ
  198.   No. of vertices in polygon 3 (Q)  v1 v2 v3 ... vQ
  199.   ...
  200.   No. of vertices in polygon P (Q)  v1 v2 v3 ... vQ
  201.   No. of polygons in object 2 (P)
  202.   No. of vertices in polygon 1 (Q)  v1 v2 v3 ... vQ
  203.   No. of vertices in polygon 2 (Q)  v1 v2 v3 ... vQ
  204.   No. of vertices in polygon 3 (Q)  v1 v2 v3 ... vQ
  205.   ...
  206.   No. of vertices in polygon P (Q)  v1 v2 v3 ... vQ
  207.   ...
  208.   No. of polygons in object M (P)
  209.   No. of vertices in polygon 1 (Q)  v1 v2 v3 ... vQ
  210.   No. of vertices in polygon 2 (Q)  v1 v2 v3 ... vQ
  211.   No. of vertices in polygon 3 (Q)  v1 v2 v3 ... vQ
  212.   ...
  213.   No. of vertices in polygon P (Q)  v1 v2 v3 ... vQ
  214.  
  215.  
  216. The structure of the objects is clearly visible by loading the supplied
  217. objects into a text editor and having a wee peek!
  218.  
  219. Future Expansion
  220. ~~~~~~~~~~~~~~~~
  221. User definable screen options.
  222. User definable colours.
  223. Better interface (gadgets or menus, haven't decided yet!).
  224. Requester for objects.
  225. Fix Phong Shading.
  226. Render into a pseudo 24-bit screen and convert to HAM image.  (I may write
  227.   this as a supplementary program in AMOS)
  228. Include the PC source to implement Wood and Marble effects.
  229. Screen Save/Print option.
  230. Better way of clearing up memory when program quits
  231.  
  232. Contact
  233. ~~~~~~~
  234. If you want the source code for this then contact me at the following
  235. address.  Please send a blank disk.  I am also open for swapping PD, hints,
  236. tips, source for any other programs etc.
  237.  
  238. James Shaw
  239. 3 Ayr Street
  240. Moniaive
  241. Dumfriesshire
  242. DG3 4HW
  243.  
  244. You could also try e-mail'ing me on
  245. ac2s20 @ uk.ac.sheffield.primee
  246. but I don't think i'll be there much longer!
  247.  
  248. Ta Ta!
  249.